package com.escafoide.smm;

import java.util.ArrayList;

import android.app.Service;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ExpenseDetailsMonthAdapter extends BaseAdapter {
	LayoutInflater inflater;
	ArrayList<String> textos = new ArrayList<String>();
	ArrayList<String> euros = new ArrayList<String>();
	Context mContext;

	public ExpenseDetailsMonthAdapter(Context con) {
		inflater = (LayoutInflater) con.getSystemService(Service.LAYOUT_INFLATER_SERVICE);
		textos.add("Nòmina");
		textos.add("Aigua");
		textos.add("Llum");
		textos.add("Telèfon");
		textos.add("Cotxe");
		euros.add("+1600");
		euros.add("-33.45");
		euros.add("-63.50");
		euros.add("-45.50");
		euros.add("-324");
		mContext = con;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return 5;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null){
			convertView = inflater.inflate(R.layout.expense_details_month_list_inflated, parent, false);
			TextView text = (TextView) convertView.findViewById(R.id.texto);
			TextView euro = (TextView) convertView.findViewById(R.id.numero);
			text.setText(textos.get(position));
			euro.setText(euros.get(position) + " €");
			if (euro.getText().toString().startsWith("-")){
				euro.setTextColor(mContext.getResources().getColor(R.color.rojo));
			} else {
				euro.setTextColor(mContext.getResources().getColor(R.color.verde));
			}
		}
		return convertView;
	}

}
